﻿using UnityEngine;
using System.Collections;
using Helper;

public class ThrowSomething : MonoBehaviour {
	[SerializeField] GameObject target;
	[SerializeField] bool startThrow = false;

	[SerializeField] Transform startTran;
	[SerializeField] Transform endTran;
	[SerializeField] float horizontalVelocity = 10f;
	[SerializeField] float gravity = 9.8f;
	[SerializeField] float regionSpeedRate = 1f;
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		if (startThrow && target!=null) {
			startThrow = false;
			Movement.MoveAlongParabolic (target, startTran.position, endTran.position, horizontalVelocity, gravity, regionSpeedRate);
		}
		if (Input.GetMouseButtonDown (0) && target!=null) {
			RaycastHit hit;
			if (Physics.Raycast (Camera.main.transform.position ,Camera.main.transform.forward, out hit)) {
				Movement.MoveAlongParabolic (target, target.transform.position, hit.point, horizontalVelocity, gravity, regionSpeedRate);
			}
		}
	}
}
